"""
@version:python3
@author:ll
@file:04-QWidget-焦点控制.py
@time:2022/2/12 23:31
"""
# 0、导入需要的包和模块
from PyQt5.Qt import *
import sys

class Window(QWidget):
    def mousePressEvent(self, evt):
        # print(self.focusWidget())
        # self.focusNextChild()
        # self.focusPreviousChild()
        self.focusNextPrevChild(True)
# 1、创建一个应用程序对象


app = QApplication(sys.argv)

# 2、控件操作
# 创建控件、设置控件、事件和信号的处理
# 2.1 创建控件
window = Window()
# 2.2 设置控件
window.setWindowTitle("焦点控制")
window.resize(500,500)

le1 = QLineEdit(window)
le1.move(50,50)

le2 = QLineEdit(window)
le2.move(100,100)

le3 = QLineEdit(window)
le3.move(150,150)

# print(le1)
# print(le2)
# print(le3)
# le2.setFocus()
# le2.setFocusPolicy(Qt.TabFocus)
# le2.setFocusPolicy(Qt.ClickFocus)
# le2.setFocusPolicy(Qt.StrongFocus)
# le2.clearFocus()

QWidget.setTabOrder(le1,le3)
QWidget.setTabOrder(le3,le2)



# 2.3 展示控件
window.show()
# le2.setFocus()
print(window.focusWidget())
# 3、应用程序的执行，进入到消息循环
sys.exit(app.exec_())